/* gm_control.h -- Faz a interface entre servidor e robôs
 *
 * Copyright (C) 2008, Diogo F. S. Ramos <diogo.ramos@usp.br>
 * GEAR - Grupo de Estudos Avançados em Robótica
 * <http://www.sel.eesc.usp.br/gear>
 *
 * This file is part os GEARMedula.
 * 
 * GEARMedula is free software: you can redistribute it and/or
 * modify it under the terms of the GNU General Public License as
 * published by the Free Software Foundation, version 3 of the
 * License.
 * 
 * GEARMedula is distributed in the hope that it will be useful, but
 * WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 * 
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see
 * <http://www.gnu.org/licenses/>.
 */

#ifndef GM_CONTROL_H_
#define GM_CONTROL_H_

#include <pthread.h>

#include "gm_sim.h"
#include "gm_serial.h"

typedef struct gm_control_t gm_control_t;
typedef struct gm_control_robot_t gm_control_robot_t;

struct gm_control_t
{
    int f_real;

    /* Representações de robôs */
    int box_size;
    gm_control_robot_t ** box;
    
};

/** Representa um robô dentro do control.
 *
 * Este objeto é utilizado para que não haja afunilamento de todos os
 * robôs atrás da mesma informação.
 *
 * Quando um robô requisita uma informação do field é deste objeto que
 * ela é retirada.
 */
struct gm_control_robot_t
{
    pthread_mutex_t mutex;

    gm_serial_t * serial;
};


gm_control_t * gm_control_new(const int f_real, const char * serial_path);
void gm_control_destroy( gm_control_t * self );

gm_control_robot_t * gm_control_robot_new( const char * end, const char * serial_path);
void gm_control_robot_destroy( gm_control_robot_t * self );
void gm_control_robot_set_vel( gm_control_t * self, const int id_robot, const float vx, const float vy, const float va);
void gm_control_robot_kick( gm_control_t * self, const int id_robot, const int nivel);
void gm_control_robot_dribble_enable( gm_control_t * self, const int id_robot, const int enable);


#endif	/* GM_CONTROL_H_ */
